cmake_minimum_required(VERSION 3.12)
project(heimdall, LANGUAGES C CXX CUDA)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_BUILD_TYPE Debug)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if(POLICY CMP0146)
    cmake_policy(SET CMP0146 OLD)
endif()

add_definitions(-DHAVE_PSRDADA)

find_package(CUDA REQUIRED)
if(CUDA_FOUND)
    set(CMAKE_CUDA_ARCHITECTURES 70;75;80;86)
    set(CMAKE_CUDA_SEPARABLE_COMPILATION ON)
    set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -diag-suppress=2417 -diag-suppress=128")
    include_directories("${CUDA_INCLUDE_DIRS}")
    link_directories(${CUDA_TOOLKIT_ROOT_DIR}/lib64)
    add_definitions(-DHAVE_CUDA)
    message(STATUS "cuda version: " ${CUDA_VERSION_STRING})
endif()

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/psrdada)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dedisp)

add_subdirectory(3rdparty)
add_subdirectory(src)
add_subdirectory(apps)
add_subdirectory(test)